package com.app.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.directwebremoting.annotations.RemoteProxy;
import org.directwebremoting.guice.ApplicationScoped;
import org.springframework.stereotype.Service;

import com.app.sso.client.servlet.OnlineCounterListener;
import com.app.sso.client.servlet.UserBean;
import com.app.util.Constant;

@Service("indexService")
//Service层
@RemoteProxy(name = "indexService")
//远程dwr组建
@ApplicationScoped
public class IndexServiceImpl implements IndexService {
	
	public UserBean getUserBean(HttpSession se){
		UserBean user = (UserBean)se.getAttribute("CNNAME");
		if(user==null){
			HttpServletRequest request = OnlineCounterListener.getHttpServletRequest();
			int num = OnlineCounterListener.clentGetServerMethod(request);
			if(num==0) {//服务器session失效 转到服务端登陆页
				user = new UserBean();
				user.setRoleID("5");
				user.setServerLogin(Constant.serverLogin);
				se.setAttribute("CNNAME", user);
			}else{
				user = (UserBean)se.getAttribute("CNNAME");
			}
		}
		System.out.println("*********************"+user.getAreaName());
		return user;
	}

}
